package com.masterclient.app.modules.order.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.baselibrary.bean.order.StorageOrderDetailData;
import com.eoner.baselib.container.CommonBaseResponse;
import com.masterclient.app.httpservice.RetrofitUtil2;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

/**
 * @auther hjian
 * @date 2020/10/23.
 */
public class StorageOrderDetailPresenter extends StorageOrderDetailContract.Presenter {
    @Override
    public void getDetailData(String order_no) {
        toSubscribe(RetrofitUtil2.getInstance().storageOrderDetail(order_no),
                new Consumer<CommonBaseResponse<StorageOrderDetailData>>() {
                    @Override
                    public void accept(@NonNull CommonBaseResponse<StorageOrderDetailData> bean) throws Exception {
                        if(bean.getCode() == 0){
                            mView.showData(bean.getData());
                        }else {
                            mView.showFailure(bean.getMsg());
                        }
                    }
                },new ThrowableConsumer(){
                    @Override
                    public void accept(Throwable o) throws Exception {
                        super.accept(o);
                        mView.showFailure("网络异常，请重试");
                    }
                });
    }
}
